define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {

        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'performance/performance/index',
                    add_url: 'performance/performance/add',
                    edit_url: 'performance/performance/edit',
                    del_url: 'performance/performance/del',
                    multi_url: 'performance/performance/multi',
                    table: 'performance',
                    edit_eva_url: 'evaluation',
                }
            });

            var table = $("#table");
            var is_super = $("#table").attr("data-is_super");
            var admin_id = $("#table").attr("data-admin-id");
            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                queryParams:function (params) {
                    
                    //自定义参数 ，固定参数不做修改
                     return {  
                        limit:params.limit,
                        search:params.search,
                        filter:params.filter,  
                        offset:params.offset,  
                        order:"performance."+params.order,  
                        sort:"performance."+params.sort,
                        admin_id:admin_id,
                       
                        
                    };
                },
                pk: 'id',
                sortName: 'id',
                cache:'false',
                pageSize : '10',
                pageList : [10,20,30],
                exportOptions: {
                    ignoreColumn: [0, -1], //默认不导出第一列(checkbox)与最后一列
                },
                // cardView:true, 与$("#table").bootstrapTable('toggleView');效果一样
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id'),operate: false},
                        {field: 'year', title: __('Year'),class:"hidden", formatter: Table.api.formatter.datetime, operate: 'RANGE', type: 'text', addclass: 'datetimepicker', data: 'data-date-format="YYYY"'},
                        {field: 'month', title: __('Month'),class:"hidden", formatter: Table.api.formatter.datetime, operate: 'RANGE', type: 'text', addclass: 'datetimepicker', data: 'data-date-format="MM"'},
                        {field: 'datekey', title: "日期",operate: false},
                        {field: 'admin_id', title:'序号', operate: false,class:"hidden"},
                        {field: 'nickname',title: '姓名',operate: false},
                        {field: 'superior_content', title:'评论',class:'text-left',operate: false},
                        {field: 'self_score', title: __('Self_score'), operate: false},
                        {field: 'superior_score', title: __('Superior_score'), operate: false},
                        {field: 'ave_score', title: __('Ave_score'), operate: false},
                        {field: 'performance',title: '当月绩效',visible:is_super,operate: false},
                      
                        {field: 'id', title: '评分',  operate: false,table: table, formatter: function (value, row, index) {
                                
                                var url = "performance/evaluation?ids="+row.id+"&admin_id="+row.admin_id+"&year="+row.year+"&month="+row.month;
                            
                                return "<a href="+url+" addtabs=\"140\" class=\"btn-addtabs\" data-title=\"自评\">评分</a>";
                            }
                        },
                                  
                    ]
                ],
                onLoadSuccess:function(){

                }
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
            // 表格展现方式 $("#table").bootstrapTable('toggleView');
      

        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});